<?php


namespace RedMVC\Form\Validator;

/**
 * AValidator class
 *  
 * @category    RedMVC
 * @package     Form
 * @subpackage  Validator 
 * @author      Jan Fischer, bitWorking <info@bitworking.de>
 */
class NotEmpty extends AValidator{
    public function isValid($value, $formValues = null){
        if(is_array($value)){
            if(count($value) > 0){
                return true;
            }
            $this->setError('FORM_VALIDATOR_NOT_EMPTY_2');
            return false;
        }
        else{
            $value = trim($value);
            if(!empty($value)){
                return true;
            }
            if($value === '0'){
                return true;
            }
            $this->setError('FORM_VALIDATOR_NOT_EMPTY_1');
            return false;
        }
    }
}